import java_cup.internal_error;
import java.util.Iterator;
import java.awt.Color;
import java.util.List;
import java.util.ArrayList;

public class Editor {
	private static List lista;
	
	public static void changeColorFigure(Figure f, Color c) {
		f.setColor(c);
	}
	
	public static void changeColorAll(Color c) {
		Figure f;
		
		for(Iterator iterator = lista.iterator(); iterator.hasNext(); ) {
			f = (Figure)iterator.next();
			f.setColor(c);
		}
	}
	
	public static void moveFigure(Figure f, int distX, int distY) {
		if(f instanceof Line)
			moveLine((Line)f, distX, distY);
		else
		if(f instanceof Rectangle)
			moveRectangle((Rectangle)f, distX, distY);
	}
	
	public static void moveLine(Line l, int distX, int distY) {	  
		l.setX(l.getX() + distX);
		l.setY(l.getY() + distY);
		l.setX2(l.getX2() + distX);
		l.setY2(l.getY2() + distY);
	}
	
	public static void moveRectangle(Rectangle r, int distX, int distY) {	  
		r.setX(r.getX() + distX);
		r.setY(r.getY() + distY);
	}
	
	public static void main(String args[]) {
		lista = new ArrayList();
		
		Line l = new Line(2, 4, 8, 12, new Color(255, 0, 0));
		lista.add(l);

		Rectangle r = new Rectangle(2, 4, 8, 8, new Color(0, 0, 255));
		lista.add(r);
		

	    changeColorAll(new Color(255, 0, 0));
	    
	    moveFigure(r, 10, -20);
	}
	
	public static Window getWindowApp() {
		return Window.getInstance(); 
	}
}
